package com.bdqn.service;

import com.bdqn.dao.SupplierMapper;
import com.bdqn.dao.SysUserMapper;
import com.bdqn.pojo.Supplier;
import com.bdqn.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

//@Transactional
@Service("supplierService") // 注册为一个Service层的Bean
public class SupplierServiceImpl implements SupplierService {
    @Autowired // @Resource
    private SupplierMapper supplierMapper;
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Supplier> SuppList(Supplier supplier) {
        try {
            return supplierMapper.SuppList(supplier);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int addSupplier(Supplier supplier) {
        supplierMapper.addSupplier(supplier);
        return 1;
    }

    @Override
    public int deleteSupplier(int id) {
        try {
            return supplierMapper.deleteSupplier(id);
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }
}
